home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2003 February 1 / MACPEOPLE-2003-02-01.ISO.7z / MACPEOPLE-2003-02-01.ISO / ぶらりオンラインウェアの旅 / おしゃべり漂流記 / xGates / xGates 1.2 Source Code.sit / xGates 1.2 Source Code / main.c < prev    next >
Text File  |  2002-12-08  |  39KB  |  1,375 lines

  1. /*
  2.     xGates -- Stunningly entertaining action game for MacOS Classic / MacOS X
  3.     Copyright (C) 2002 Sveinbjorn Thordarson <paladeen@soth.zoneit.com>
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     main.c - main program file
  20.  
  21. */
  22.  
  23.  
  24. //my headers
  25.     #include "definitions.h"
  26.     #include "prototypes.h"
  27.     #include "structures.h"
  28.     #include "externs.h"
  29.  
  30.  
  31. ////////////////////////////////////////
  32. //Colors
  33. ////////////////////////////////////////
  34.  
  35. RGBColor myBlackColor = { 0, 0, 0 };
  36. RGBColor myWhiteColor = { 65535, 65535, 65535 };
  37. RGBColor myRedColor = { 65535, 0, 0 };
  38. RGBColor myGreenColor = { 0, 65535, 0 };
  39. RGBColor myBlueColor = { 0, 0, 65535 };
  40. RGBColor myVeryLightGreyColor = { 50000, 50000, 50000 };
  41. RGBColor myLightGreyColor = { 35000, 35000, 35000 };
  42. RGBColor myGrayColor = {16000, 16000, 16000};
  43. RGBColor myDarkGrayColor = { 12000, 12000, 12000 };
  44. RGBColor myGrayBlueColor = { 40000, 40000, 55000 };
  45.  
  46.  
  47. ////////////////////////////////////////
  48. //rects for offworld pics to copy from
  49. ////////////////////////////////////////
  50.  
  51. Rect        poofSizes[5] = { { 0, 0, 52, 42 }, { 0, 42, 52, 84 }, { 0, 84, 52, 126 }, {0, 126, 52, 168 }, { 0, 168, 52, 210 } };
  52. Rect        highscoreSize = { 0, 0, 446, 234  };
  53. Rect        gameTitleSize = { 0, 0, 91, 313 };
  54. Rect        dojSize = { 0, 0, 50, 50 };
  55. Rect        macIconSizes[2] = { { 0, 0, 37, 40 },{ 0, 40, 37, 80 } };
  56. Rect        billIconSize = { 0, 0, 40, 31 };
  57. Rect        chainsawSizes[2] = { { 0, 0, 32, 32 }, { 0, 32, 32, 64 } };
  58. Rect        cornerSize = { 0, 0, 8, 8 };
  59. Rect        chainsawBigSize = { 0, 0, 174, 300 };
  60. Rect        scoreNamePicSize = { 0, 0, 23, 146 };
  61. Rect        haukurSplashSize = { 0, 0, 281, 300 };
  62. Rect        haukurHeadSize = { 0, 0, 461, 582 };
  63. Rect        haukurWinSize = { 0, 0, 460, 323 };
  64. Rect        sothPicSize = { 0, 0, 100, 103 };
  65.  
  66.  
  67. ////////////////////////////////////////
  68. //update rects for optimal drawing method
  69. ////////////////////////////////////////
  70. Rect        updateRects[kMaxUpdateRects];
  71. short       gNumUpdateRects; 
  72.  
  73. Rect        dojCountUpdateRect = { 465, 45, 477, 165 };
  74. Rect        billCountUpdateRect = { 465, 337, 477, 370 };
  75. Rect        scoreCountUpdateRect = { 465, 500, 477, 600 };
  76.  
  77.  
  78. Rect        gamePausedPicRect = { 215, 260, 245, 380 };
  79. Rect         fpsRect = { 15, 585, 35, 632 };
  80.  
  81. ////////////////////////////////////////
  82. //bill animation pics
  83. Rect    billRects[6] = { { 0, 0, 64, 50 }, { 0, 50, 64, 100 }, { 0, 100, 64, 150 }, { 0, 150, 64, 200}, { 0, 200, 64, 250}, { 0, 250, 64, 300 }};
  84. ////////////////////////////////////////
  85.  
  86.  
  87.  
  88.  
  89.  
  90. ///main screen
  91. Rect billHeadRect = { 160, 360, 260, 425 };
  92. Rect nedHeadRect = { 115, 435, 220, 510 };
  93. Rect chainsawRect = { 322, 332, 377, 385 };
  94.  
  95.  
  96.  
  97.     //pic rects for blitting mac sprites
  98. Rect    macRects[10][6] ={  {     { 0, 0, 52, 56}, { 0, 56, 52, 112},{ 0, 112, 52, 168}, { 0, 168, 52, 224} },
  99.                                 { { 0, 0, 52, 82}, { 0, 82, 52, 164},{ 0, 164, 52, 246}, { 0, 246, 52, 328} },
  100.                                 { { 0, 0, 47, 86}, { 0, 86, 47, 172},{ 0, 172, 47, 258}, { 0, 258, 47, 344} },
  101.                                 { { 0, 0, 56, 82}, { 0, 86, 56, 164},{ 0, 164, 56, 246}, { 0, 246, 56, 328} }, 
  102.                                 { { 0, 0, 58, 56}, { 0, 56, 58, 112},{ 0, 112, 58, 168}, { 0, 168, 58, 224} },
  103.                                 { { 0, 0, 52, 90}, { 0, 90, 52, 180},{ 0, 180, 52, 270}, { 0, 270, 52, 360} },
  104.                                 { { 0, 0, 41, 42}, { 0, 42, 41, 84}, { 0, 84, 41, 126}, { 0, 126, 41, 168} },
  105.                                 { { 0, 0, 46, 50}, { 0, 50, 46, 100},{ 0, 100, 46, 150}, { 0, 150, 46, 200} },
  106.                                 { { 0, 0, 33, 40}, { 0, 40, 33,  80},{ 0, 80, 33, 120}, { 0, 120, 33, 160} },
  107.                                 { { 0, 0, 47, 60}, { 0, 60, 47, 120},{ 0, 120, 47, 180}, { 0, 180, 47, 240} }
  108.                             };
  109. Rect    macScreenRects[10] = { { 6, 10, 31, 45 }, { 7, 11, 34, 43 }, { 7, 40, 31, 79 }, { 7, 10, 33, 45 }, { 6, 6, 32, 49 },
  110.                                 { 6, 6, 35, 55 }, { 5, 9, 23, 32 }, { 3, 8, 28, 41 }, { 3, 6, 22, 33 }, { 2, 7, 31, 51 } };
  111.     
  112.     //splash buttons                        
  113. Rect    splashButtonSizes[6] = {     { 0, 0, 30, 120 },  { 30, 0, 60, 120 }, { 60, 0, 90, 120 }, 
  114.                                                 { 90, 0, 120, 120 },{ 120,0,150, 120 }, { 150, 0, 180, 120 } };
  115.                                                 
  116.                                                 
  117. //actual onscreen rects for pics
  118.  
  119. Rect    splashButtonRects[6] = {    { 388, 250, 418, 370 }, { 388, 380, 418, 500 }, //new game/configure
  120.                                 { 388, 510, 418, 630 },{ 428, 250, 458, 370 }, //credits/about
  121.                                { 428, 380, 458, 500 }, { 428, 510, 458, 630 } };
  122.    
  123.  
  124. //start locs for bills
  125. Point           billStartLocs[8] = { { 0, 0 }, { 0,295 }, { 0, 590 }, { 198,590 }, { 396,590 }, { 396,295 }, { 396,0 }, { 198,0 } };
  126.  
  127.  
  128.  
  129.  
  130.  
  131. //app vars
  132. short       gDone = false;
  133. short       gPlaying = false;
  134. short          gWhere = 0;
  135.  
  136. //in game, glob vars
  137. short            pauseTime;
  138. short           dojCooldown = 0;
  139. short           levelScore = 0;
  140. short           cheated = false;
  141. short           currentLevel;
  142.  
  143. short           currentBillSpeed;
  144. short           lastBillStartLoc;
  145.  
  146. short           billsInLevel;
  147. short           levelCompleted = 0;
  148. short           numOfBills = 0;
  149. short           numOfSteves = 0;
  150. short           numOfDojs = 0;
  151. short           numOfPoofs  = 0;
  152. short           weaponState = 0;
  153.  
  154. //mouse game vars
  155. short            mouseDownLast = false;
  156. short            mouseCount = 0;
  157. short            mouseCountdown = 0;
  158. short            mouseJammed = false;
  159.  
  160.  
  161. //contains data about the current player
  162. PlayerStruct    player;
  163. //game preferences
  164.  
  165. PrefsStruct     prefs;
  166.  
  167. //data on Dept. of Justices in level
  168. DojStruct       dojs[2];
  169.  
  170. //poofs in level
  171. PoofStruct      poofs[kMaxPoofLimit];
  172.  
  173. //bills structure - keeps track of all bills in level
  174. BillStruct  bills[kMaxBills];
  175.  
  176. //this is the struct that keeps track of Steve.  Ironically enough, it's a BillStruct
  177. BillStruct  steve;
  178.  
  179.  
  180.  
  181.  
  182.  
  183. //levels structure
  184. LevelStruct levels[kNumOfLevels] = {     //  { 3, 30, 0, 2, 0, {{ kiMac, kMacOS, 230, 180      }, { kiMac, kMacOS, 280, 245         }, { kiMac, kMacOS, 330, 180}                                                                                            }        },  
  185.                                             { 3, 40, 0, 3, 0,{{ kiMac, kMacOS, 230, 245, 0   }, { kiMac, kMacOS, 330, 245         }, { kYosemite,   kMacOS, 280, 180}                                                                                        }        },
  186.                                             { 4, 45, 0, 4, 0,{{ kYosemite, kMacOS, 190,210, 0}, { kYosemite, kMacOS, 250, 300     }, { kSawtooth,   kMacOS, 300, 220},    { kYosemite,  kMacOS, 350, 160}                                                   }        },
  187.                                             { 3, 50, 1, 3, 1,{{ kiMac, kMacOS, 220, 218, 0   }, { kSawtooth, kMacOS, 300, 190     }, { kYosemite,  kMacOS, 300, 260}                                                                                        }        },
  188.                                             { 5, 55, 0, 3, 1,{{ kSawtooth,kMacOS, 183, 160}, { kSawtooth, kMacOS, 187, 250     }, { kCube,  kMacOS, 295, 195},         { kSawtooth,  kMacOS, 395, 160},     { kSawtooth,  kMacOS, 380, 260}                }       },
  189.                                             //{ 3, 40, 0, 4, 1,{{ kCube, kMacOS, 230, 180   }, { kSawtooth, kMacOS, 280, 260     }, { kCube,  kMacOS, 330, 190}                                                                                            }          },
  190.                                             { 4, 60, 0, 5, 1,{{ kiBook, kMacOS, 180, 160, 0  }, { kYosemite, kMacOS, 295, 195     }, { kiBook,   kMacOS, 280, 275},         { kiBook,  kMacOS, 395, 160}                                                     }        },
  191.                                             { 3, 65, 1, 3, 2,{{ kiBook, kMacOS, 360, 200, 0  }, { kNewiMac, kMacOS, 250, 180     }, { kPismo,   kMacOS, 225, 265}                                                                                         }         },
  192.                                             { 5, 70, 0, 4, 2,{{ kiBook, kMacOS, 200, 160, 0  }, { kiBook, kMacOS, 400, 160         }, { kNewiMac, kMacOS, 284, 195 },         { kPismo,   kMacOS, 195, 265},         { kPismo,   kMacOS, 385, 265}                }        },
  193.                                              { 3, 75, 0, 5, 2,{{ kSawtooth, kMacOS, 184,152, 0}, { kQuicksilver, kMacOS, 252, 213}, { kSawtooth,   kMacOS, 340, 270}                                                                                     }         },
  194.                                              { 4, 80, 1, 6, 2,{{ kNewiMac, kMacOS, 272, 255, 0}, { kQuicksilver, kMacOS, 220, 196}, { kQuicksilver,   kMacOS, 315, 196}, { kNewiMac,  kMacOS, 272, 134}                                                     }        },
  195.                                              { 3, 85, 0, 3, 2,{{ kSawtooth, kMacOS, 180,152, 0}, { kQuicksilver, kMacOS, 270, 200}, { kYosemite,   kMacOS, 360, 260}                                                                                     }         },
  196.                                              { 5, 90, 0, 4, 2,{{ kiBook, kMacOS, 266, 138, 0  }, { kQuicksilver, kMacOS, 305, 185}, { kQuicksilver, kMacOS, 200, 185 },     { kPismo,   kMacOS, 237, 265},         { kiMac,   kMacOS, 385, 265}                }        },
  197.                                              { 2, 95, 1, 5, 3,{{ kTiBook, kMacOS, 190,180, 0     }, { kTiBook, kMacOS, 390, 180        }                                                                                                                        }         },
  198.                                              { 5, 100, 0, 4, 3,{{ kNewiBook, kMacOS, 200,140, 0}, { kNewiBook, kMacOS, 400, 140    }, { kQuicksilver, kMacOS, 275, 195},    { kNewiBook, kMacOS, 200,270},         { kNewiBook, kMacOS, 400, 270}                }        },
  199.                                              { 3, 105, 0, 3, 3,{{ kCube, kMacOS, 170,195, 0     }, { kQuicksilver, kMacOS, 280, 210}, { kCube,   kMacOS, 390, 195}                                                                                         }         },
  200.                                              { 4, 110, 1, 3, 3,{{ kCube, kMacOS, 215, 170, 0     },    { kCube, kMacOS, 335, 170        }, { kQuicksilver,   kMacOS, 215, 235}, { kQuicksilver,  kMacOS, 335, 235}                                                 }        },
  201.                                              { 3, 115, 0, 4, 3,{{kQuicksilver,kMacOS,275,135, 0},    { kQuicksilver, kMacOS,275,205    }, { kQuicksilver,   kMacOS, 275, 275}                                                                                     }         },
  202.                                              { 5, 120, 0, 5, 4,{{ kNewiMac,kMacOS, 183, 160, 0 },    { kNewiMac, kMacOS, 187, 250    }, { kTiBook,  kMacOS, 295, 195},         { kNewiMac,  kMacOS, 395, 160},     { kNewiMac,  kMacOS, 380, 260}                }       },
  203.                                              //{ 2, 80, 1, 3, 4,{{ kNewiBook, kMacOS, 265,180}, { kNewiBook, kMacOS, 315, 180    }                                                                                                                        }         },
  204.                                              { 3, 125, 1, 4, 4,{{ kiMac,kMacOS, 190,220, 0     },    { kNewiMac, kMacOS,275,150        }, { kiMac,   kMacOS, 390, 220}                                                                                         }         },                            
  205.                                              { 6, 130, 0, 4, 4,{{ kiMac, kMacOS, 150, 150, 0   }, { kiMac, kMacOS, 275, 150        }, { kiMac, kMacOS, 400, 150 }, { kiMac,   kMacOS, 150, 270}, { kiMac,   kMacOS, 275, 270},{ kiMac,   kMacOS, 400, 270} }        },
  206.                                              { 4, 135, 0, 5, 4,{{ kYosemite, kMacOS, 170,180, 0},    { kYosemite, kMacOS, 350, 180    }, { kYosemite,   kMacOS, 205, 244},     { kYosemite,  kMacOS, 305, 244}                                                 }        },
  207.                                              { 2, 140, 1, 2, 5,{{ kPismo, kMacOS, 280,180, 0     }, { kPismo, kMacOS, 270, 240        }                                                                                                                        }         },
  208.                                              //{ 3, 90, 0, 3, 5,{{ kNewiBook,kMacOS, 195,230 },    { kSawtooth, kMacOS,255,175        }, { kNewiBook,   kMacOS, 390, 150}                                                                                     }         },
  209.                                              //{ 4, 95, 0, 4, 5,{{ kCube, kMacOS, 215, 170     },    { kCube, kMacOS, 335, 170        }, { kQuicksilver,   kMacOS, 215, 235}, { kQuicksilver,  kMacOS, 335, 235}                                                 }        },
  210.                                              { 4, 145, 0, 3, 5,{{ kSawtooth, kMacOS, 170,205, 0},    { kCube, kMacOS, 370, 205        }, { kQuicksilver,   kMacOS, 260, 147}, { kYosemite,  kMacOS, 270, 250}                                                 }        },
  211.                                              { 6, 150, 0, 4, 5,{{ kiMac, kMacOS, 150, 140 , 0  }, { kYosemite, kMacOS, 380, 150    }, { kSawtooth, kMacOS, 240, 150 },{ kCube,   kMacOS, 150, 270},{ kNewiMac, kMacOS, 275, 270},{ kQuicksilver,kMacOS, 400, 270} }},
  212.                                              { 4, 155, 1, 4, 5,{{ kiBook, kMacOS, 170,195, 0     }, { kPismo, kMacOS, 230, 210}, { kNewiBook,   kMacOS, 310, 185},{ kTiBook,   kMacOS, 410, 195}                                                             }         }
  213.                                          };
  214.  
  215.  
  216. FSSpec          prefsFile;
  217.  
  218.  
  219.  
  220.  
  221.  
  222. Rect    gameScreenSize = { 0, 0, 460, 640 };
  223. Rect    barRect = { 460, 0, 480, 640 };
  224. Rect    winRect = { 100, 100, 580, 740 };
  225. Rect    screenSize = { 0, 0, 480, 640 };
  226.  
  227. Boolean    gOS;
  228.  
  229. //menus
  230. MenuHandle  appleMenu;
  231. MenuHandle  fileMenu;
  232. MenuHandle  editMenu;
  233. MenuHandle  optionsMenu;
  234. MenuHandle  geekOptionsMenu;
  235.  
  236.  
  237.  
  238.  
  239. PixMapHandle    billPix;
  240. GWorldPtr       billPtr;
  241.  
  242. PixMapHandle    stevePix;
  243. GWorldPtr       stevePtr;
  244.  
  245. PixMapHandle    workMapPix;
  246. GWorldPtr       workMapPtr;
  247.  
  248. PixMapHandle    macPix[10];
  249. GWorldPtr       macPtr[10];
  250.  
  251. PixMapHandle    chainSawPix;
  252. GWorldPtr       chainSawPtr;
  253.  
  254. PixMapHandle    chainSawBigPix;
  255. GWorldPtr       chainSawBigPtr;
  256.  
  257. PixMapHandle    splashPix;
  258. GWorldPtr       splashPtr;
  259.  
  260. PixMapHandle    highScorePix;
  261. GWorldPtr        highScorePtr;
  262.  
  263. PixMapHandle    buttonsPix;
  264. GWorldPtr       buttonsPtr;
  265.  
  266. PixMapHandle    deptOfJusticePix;
  267. GWorldPtr       deptOfJusticePtr;
  268.  
  269. PixMapHandle    macIconPix;
  270. GWorldPtr       macIconPtr;
  271.  
  272. PixMapHandle    billIconPix;
  273. GWorldPtr       billIconPtr;
  274.  
  275. PixMapHandle    deptOfJusticeIconPix;
  276. GWorldPtr       deptOfJusticeIconPtr;
  277.  
  278. PixMapHandle    poofPix;
  279. GWorldPtr       poofPtr;
  280.  
  281. PixMapHandle    sothPix;
  282. GWorldPtr       sothPtr;
  283.  
  284. PixMapHandle    mousePix;
  285. GWorldPtr       mousePtr;
  286.  
  287. PixMapHandle    keyboardPix;
  288. GWorldPtr       keyboardPtr;
  289.  
  290. PixMapHandle    gamePausedPix;
  291. GWorldPtr       gamePausedPtr;
  292.  
  293. PixMapHandle    cornerPix[2];
  294. GWorldPtr       cornerPtr[2];
  295.  
  296. PixMapHandle     scoreNameRectPix;
  297. GWorldPtr        scoreNameRectPtr;
  298.  
  299. PixMapHandle     haukurSplashPix;
  300. GWorldPtr        haukurSplashPtr;
  301.  
  302. PixMapHandle     haukurHeadPix;
  303. GWorldPtr        haukurHeadPtr;
  304.  
  305. PixMapHandle     haukurWinPix;
  306. GWorldPtr        haukurWinPtr;
  307.  
  308. PixMapHandle     sothGuysPix;
  309. GWorldPtr        sothGuysPtr;
  310.          
  311. //SOUNDS
  312.  
  313.     //weapon sounds
  314.     Handle          chainsawSnd;
  315.     Handle          jammedSnd;
  316.  
  317.     //bill sounds
  318.     Handle          billScreamSnd;
  319.     Handle          billLaughSnd;
  320.     Handle          billIndignantSnd;
  321.     Handle          billBriefcaseSnd;
  322.  
  323.     //steve sounds
  324.     Handle          steveAppearsSnd;
  325.     Handle          steveScreamSnd;
  326.     Handle          steveInstallsSnd;
  327.  
  328.     //computer sounds
  329.     Handle          macOSLoadedSnd;
  330.     Handle          winXPLoadedSnd;
  331.     
  332.     //dept of justice sounds
  333.     Handle          dojUsedSnd;
  334.     Handle          dojAppearsSnd;
  335.     Handle          dojCaughtSnd;
  336.     
  337.     //other sounds
  338.     Handle          bonkSnd;
  339.     Handle          zoomSnd;
  340.     Handle          poofSnd;
  341.     Handle            gongSnd;
  342.     Handle           beepSnd;
  343.     
  344.     //game sounds
  345.     Handle          gameOverSnd;
  346.     Handle          gamePausedSnd;
  347.     Handle            yeahSnd;
  348.     Handle          killSomeBillSnd;
  349.     Handle          goodJobSound;
  350.     
  351.     //music sounds
  352.     Handle          musicSounds[6];
  353.  
  354.     //game sound channels
  355.     SndChannelPtr   weaponSndChannel;
  356.     SndChannelPtr   billSndChannel;
  357.     SndChannelPtr   steveSndChannel;
  358.     SndChannelPtr   computerSndChannel;
  359.     SndChannelPtr   dojSndChannel;
  360.     SndChannelPtr   otherSndChannel;
  361.     //music channel
  362.     SndChannelPtr   musicSndChannel;                                       
  363.                                                 
  364.     Rect            textFieldRect = { 360, 50, 377, 190 };
  365.     TEHandle        playerNameTextField;
  366.     Str255            playerName;
  367.     
  368.     DSpContextReference  gDisplayContext;
  369.     DSpContextAttributes gDisplayAttributes;   
  370.  
  371.  
  372. //////////////////////////////////////////////////////
  373. //main program function. Init and enter event loop
  374. //////////////////////////////////////////////////////
  375.  
  376. int main(void)
  377. {
  378.     EventRecord     theEvent;
  379.     long            caretTime = GetCaretTime();//get caret time in case of text blinking
  380.     Boolean         wasProcessed;
  381.     
  382.  
  383.     //load OS stuff
  384.     InitToolbox();
  385.     
  386.     //read preferences file
  387.     LoadPrefs();
  388.  
  389.         DisplayInit();
  390.     
  391.     //install apple event handlers
  392.     AppleEventInit();
  393.     
  394.     //install menus
  395.     InitMenus();
  396.     //load pixmaps to memory
  397.     InitGraphics();
  398.     //load sound resources and channels
  399.     InitSound();
  400.     
  401.     HideCursor();
  402.     
  403.     //draw soth screen
  404.     DrawSothScreen();
  405.     
  406.     BlitWorkMapToScreen();
  407.     
  408.         //play gong
  409.         if (prefs.sound)
  410.         {
  411.             SndPlay(otherSndChannel, (SndListHandle)gongSnd, true);
  412.         }
  413.     
  414.     Sleep(80);
  415.     
  416.     //zoom out to splash screen
  417.     DoSplashScreen();
  418.     
  419.     ShowCursor();
  420.     
  421.     //define starting location
  422.     gWhere = kSplashScreen;
  423.  
  424.     
  425.     //begin application event loop
  426.     do
  427.     {
  428.         if(gPlaying == true && gWhere == kPlayingGame)
  429.         {
  430.             DoGameFrame();
  431.         }
  432.         else
  433.         {
  434.             WaitNextEvent(everyEvent, &theEvent, caretTime, nil);
  435.             
  436.             DSpProcessEvent (&theEvent, &wasProcessed);
  437.  
  438.             if (!wasProcessed)
  439.                 HandleEvent(&theEvent);
  440.                 
  441.             SetMenuStatus();
  442.             
  443.             //blinking text insert if we're in highscore entry
  444.             if (gWhere == kHighScore)
  445.                 TEIdle(playerNameTextField);
  446.             
  447.         }
  448.     } while (!gDone);
  449.     
  450.     QuitApp();
  451.     
  452.     return(0);
  453. }
  454.  
  455.  
  456.  
  457. //////////////////////////////////////////////////////
  458. //Clean up and exit application
  459. //////////////////////////////////////////////////////
  460.  
  461. void QuitApp (void)
  462. {
  463.     //save preferences
  464.     WritePrefs();
  465.     gDone = true;
  466.     
  467.     //silence
  468.     SilenceAllChannels();
  469.     
  470.     DSpShutdown();
  471.     
  472.     //exit
  473.     ExitToShell();
  474. }
  475.  
  476.  
  477. //////////////////////////////////////////////////////
  478. //Determine which menus are active, which items are checked, etc
  479. //////////////////////////////////////////////////////
  480.  
  481. void SetMenuStatus (void)
  482. {
  483.     if(gPlaying)
  484.     {
  485.         DisableMenuItem(appleMenu, 1);
  486.         DisableMenuItem(fileMenu, 1);
  487.         
  488.         DisableMenuItem(fileMenu, 4);
  489.         DisableMenuItem(fileMenu, 5);
  490.         DisableMenuItem(fileMenu, 6);
  491.         DisableMenuItem(fileMenu, 7);
  492.         DisableMenuItem(fileMenu, 8);
  493.         DisableMenuItem(fileMenu, 9);
  494.        
  495.         
  496.         EnableMenuItem(fileMenu, 2);
  497.     
  498.         //options menu
  499.         EnableMenuItem(optionsMenu, 8);
  500.  
  501.         
  502.         if (gWhere == kGamePaused)
  503.         {
  504.             CheckMenuItem(optionsMenu, 5, 1);
  505.         }
  506.         else
  507.         {
  508.             CheckMenuItem(optionsMenu, 5, 0);
  509.         }
  510.         
  511.            //geek options menu
  512.            EnableMenuItem(geekOptionsMenu, 1);
  513.            EnableMenuItem(geekOptionsMenu, 3);
  514.            EnableMenuItem(geekOptionsMenu, 5);
  515.        
  516.            if (prefs.fixedFrameRate)
  517.            {
  518.             EnableMenuItem(geekOptionsMenu, 6);
  519.                EnableMenuItem(geekOptionsMenu, 7);
  520.                EnableMenuItem(geekOptionsMenu, 8);
  521.            }
  522.            else
  523.            {
  524.                DisableMenuItem(geekOptionsMenu, 6);
  525.                DisableMenuItem(geekOptionsMenu, 7);
  526.                DisableMenuItem(geekOptionsMenu, 8);
  527.            }
  528.        
  529.            EnableMenuItem(geekOptionsMenu, 10);
  530.            
  531.            DisableMenuItem(geekOptionsMenu, 12);
  532.         
  533.     }
  534.     else if (gWhere == kHighScore)
  535.     {
  536.         //file menu
  537.         DisableMenuItem(fileMenu, 1);
  538.         DisableMenuItem(fileMenu, 2);
  539.         DisableMenuItem(fileMenu, 3);
  540.         DisableMenuItem(fileMenu, 4);
  541.         DisableMenuItem(fileMenu, 5);
  542.         DisableMenuItem(fileMenu, 6);
  543.         DisableMenuItem(fileMenu, 7);
  544.         DisableMenuItem(fileMenu, 8);
  545.         DisableMenuItem(fileMenu, 9);
  546.         
  547.         //options menu
  548.         DisableMenuItem(optionsMenu, 5);
  549.         
  550.         //geek options menu
  551.  
  552.            DisableMenuItem(geekOptionsMenu, 1);
  553.            DisableMenuItem(geekOptionsMenu, 3);
  554.            DisableMenuItem(geekOptionsMenu, 5);
  555.            DisableMenuItem(geekOptionsMenu, 6);
  556.            DisableMenuItem(geekOptionsMenu, 7);
  557.            DisableMenuItem(geekOptionsMenu, 8);
  558.             
  559.            EnableMenuItem(geekOptionsMenu, 10);
  560.             DisableMenuItem(geekOptionsMenu, 12);
  561.     }
  562.     else
  563.     {
  564.         EnableMenuItem(appleMenu, 1);
  565.     
  566.         //file menu
  567.         EnableMenuItem(fileMenu, 1);
  568.         EnableMenuItem(fileMenu, 4);
  569.         EnableMenuItem(fileMenu, 5);
  570.         EnableMenuItem(fileMenu, 6);
  571.         EnableMenuItem(fileMenu, 7);
  572.         EnableMenuItem(fileMenu, 8);
  573.         EnableMenuItem(fileMenu, 9);
  574.         DisableMenuItem(fileMenu, 2);
  575.     
  576.         //options menu
  577.         DisableMenuItem(optionsMenu, 5);
  578.         
  579.         //geek options menu
  580.             EnableMenuItem(geekOptionsMenu, 1);
  581.             EnableMenuItem(geekOptionsMenu, 3);
  582.             EnableMenuItem(geekOptionsMenu, 5);
  583.             
  584.             if (prefs.fixedFrameRate)
  585.             {
  586.                 EnableMenuItem(geekOptionsMenu, 6);
  587.                 EnableMenuItem(geekOptionsMenu, 7);
  588.                 EnableMenuItem(geekOptionsMenu, 8);
  589.             }
  590.             else
  591.             {
  592.                 DisableMenuItem(geekOptionsMenu, 6);
  593.                 DisableMenuItem(geekOptionsMenu, 7);
  594.                 DisableMenuItem(geekOptionsMenu, 8);
  595.             }
  596.             
  597.             EnableMenuItem(geekOptionsMenu, 10);
  598.             if (gWhere == kSplashScreen)
  599.                 EnableMenuItem(geekOptionsMenu, 12);
  600.     }
  601.  
  602.  
  603.     //checkmarks in the right places
  604.  
  605.  
  606.     //option menu    
  607.     if (prefs.sound)
  608.         CheckMenuItem(optionsMenu, 1, true);
  609.     else
  610.         CheckMenuItem(optionsMenu, 1, false);
  611.         
  612.     if (prefs.music)
  613.         CheckMenuItem(optionsMenu, 2, true);
  614.     else
  615.         CheckMenuItem(optionsMenu, 2, false);
  616.  
  617.  
  618.       
  619.       //geek options menu
  620.  
  621.           if (prefs.noChainsawJamming)
  622.             CheckMenuItem(geekOptionsMenu, 1, true);
  623.         else
  624.             CheckMenuItem(geekOptionsMenu, 1, false);
  625.       
  626.           if (prefs.fixedFrameRate)
  627.             CheckMenuItem(geekOptionsMenu, 3, true);
  628.         else
  629.             CheckMenuItem(geekOptionsMenu, 3, false);
  630.           
  631.         if (prefs.drawFPS)
  632.             CheckMenuItem(geekOptionsMenu, 4, true);
  633.         else
  634.             CheckMenuItem(geekOptionsMenu, 4, false);
  635.             
  636.             
  637. }
  638.  
  639.  
  640.  
  641. #pragma mark -
  642.  
  643. //////////////////////////////////////////////////////
  644. //Event controller, really
  645. //////////////////////////////////////////////////////
  646.  
  647.  
  648. void HandleEvent (EventRecord *myEvent)
  649. {
  650.     
  651.     switch(myEvent->what)
  652.     {
  653.             case keyDown:
  654.             case autoKey:
  655.                 HandleKey(myEvent);
  656.                 break;
  657.             case kHighLevelEvent:
  658.                 HandleHLEvent(myEvent);
  659.                 break;
  660.             case activateEvt:
  661.                 break;
  662.             case updateEvt:
  663.                 HandleUpdate();
  664.                 break;
  665.             case mouseDown:
  666.                 HandleMouse(myEvent);
  667.                 break;
  668.             case osEvt:
  669.                 HandleOSEvent(myEvent);
  670.                 break;
  671.     }
  672. }
  673.  
  674.  
  675.  
  676.  
  677. //////////////////////////////////////////////////////
  678. //Handle OS events
  679. //////////////////////////////////////////////////////
  680.  
  681. void HandleOSEvent (EventRecord *myEvent)
  682. {
  683.     if (myEvent->message & 0x01000000)        //・    Suspend/resume event
  684.     {
  685.         if (myEvent->message & 0x00000001)    //・    Resume
  686.         {
  687.         }
  688.         else
  689.         {
  690.             EventRecord    theEvent;
  691.  
  692.             while (true)
  693.             {
  694.                 //・    Only check for resume and update events.  While doing so, give TONS of time to other apps
  695.                 if (WaitNextEvent(osMask, &theEvent, 32767, nil))
  696.                 {
  697.                     if (theEvent.message & 0x01000000)        //・    Suspend/resume event
  698.                     {
  699.                         if (theEvent.message & 0x00000001)    //・    Resume
  700.                         {
  701.                             Boolean    dummy;
  702.  
  703.                             //・    Make sure that DrawSprocket knows that we've resumed
  704.                             DSpProcessEvent(&theEvent, &dummy);
  705.  
  706.                         }
  707.                         break;
  708.                     }
  709.                 }
  710.             }
  711.             
  712.             HandleUpdate();
  713.         }
  714.     }
  715.  
  716.  
  717. }
  718.  
  719.  
  720. //////////////////////////////////////////////////////
  721. //Handle key stroke events
  722. //////////////////////////////////////////////////////
  723.  
  724.  
  725. void HandleKey (EventRecord *theEvent)
  726. {
  727.     long            menuChoice;
  728.     char            theKey;
  729.     long            strLen = 0;
  730.     
  731.     theKey = (char)(theEvent->message & charCodeMask);
  732.     
  733.     //just do the menu shortcut key command
  734.     if (theEvent->modifiers & cmdKey)
  735.     {
  736.         menuChoice = MenuKey(theKey);
  737.         
  738.         if (HiWord(menuChoice))
  739.         {
  740.             HandleMenus(menuChoice);
  741.             HiliteMenu(menuChoice);
  742.         }
  743.     }
  744.     
  745.     
  746.     
  747.     
  748.     //IF WE'RE ASKING FOR NAME FOR HIGH SCORE CHART
  749.     if (gWhere == kHighScore)
  750.     {
  751.         //if enter button is pressed, highlight OK and close
  752.         if ( (theKey == (char)13) || (theKey == (char)3))
  753.         {    
  754.             strLen = (**playerNameTextField).teLength;
  755.             if (strLen < 1)
  756.             {
  757.                 if (prefs.sound)
  758.                 {
  759.                     SilenceChannel(billSndChannel);
  760.                     SndPlay(billSndChannel, (SndListHandle)billScreamSnd, true);
  761.                     return;
  762.                 }
  763.             }
  764.             
  765.             //add player into list and adjust
  766.             AddScoreToHighScoreChart();
  767.             
  768.             TEDeactivate(playerNameTextField);
  769.             TEDispose(playerNameTextField);
  770.  
  771.             EndGame();
  772.         }
  773.         else
  774.         {
  775.             strLen = (*playerNameTextField)->teLength;
  776.             if (theKey == 8)//delete
  777.             {
  778.                 TEKey(theKey, playerNameTextField);
  779.             }
  780.             else if (strLen < 15)
  781.             {
  782.                 TEKey(theKey, playerNameTextField);
  783.             }
  784.             else
  785.             {
  786.                 if (prefs.sound)
  787.                 {
  788.                     SilenceChannel(billSndChannel);
  789.                     SndPlay(billSndChannel, (SndListHandle)billScreamSnd, true);
  790.                 }
  791.             }
  792.         }
  793.         
  794.     }
  795.     
  796.     
  797.     //IF PAUSED
  798.     if (gWhere == kGamePaused && theKey == 'q')
  799.     {
  800.         GameOver();
  801.     }
  802.     
  803.     if (gOS == kMacOSX && (gWhere == kSplashScreen) )
  804.     {
  805.         if (theKey == 'q')
  806.         {
  807.             QuitApp();
  808.         }
  809.     
  810.     }
  811. }
  812.  
  813.  
  814.  
  815. //////////////////////////////////////////////////////
  816. ////Process Apple Events
  817. //////////////////////////////////////////////////////
  818.  
  819. void HandleHLEvent (EventRecord *myEvent)
  820. {
  821.      AEProcessAppleEvent(myEvent);
  822. }
  823.  
  824.  
  825.  
  826. //////////////////////////////////////////////////////
  827. ////Handle menu selection
  828. //////////////////////////////////////////////////////
  829.  
  830. void HandleMenus(long menuChoice)  
  831. {
  832.     short            menuID     = HiWord(menuChoice);
  833.     short            menuItem   = LoWord(menuChoice);
  834.     
  835.     switch (menuID)
  836.     {
  837.     
  838.         //Apple Menu
  839.         case 128:
  840.             {
  841.             
  842.                 switch(menuItem)
  843.                 {
  844.                     case 1:
  845.                         DoCredits();
  846.                         break;
  847.                         
  848.                     default:
  849.                         break;
  850.                 }
  851.             }
  852.             break;
  853.         
  854.         //File Menu
  855.         case 1001:
  856.             switch(menuItem)
  857.             {
  858.                 //Start game
  859.                 case 1:
  860.                                     NewGame();
  861.                     break;
  862.                 
  863.                 //End game
  864.                 case 2:
  865.                                     GameOver();
  866.                     break;
  867.                     
  868.                             //seperator
  869.                 case 3:
  870.                     break;
  871.                             
  872.                 //Clear high score
  873.                 case 4:
  874.                     if (prefs.sound)
  875.                     {
  876.                         SndPlay(computerSndChannel, (SndListHandle)winXPLoadedSnd, true);
  877.                     }
  878.                     ClearHighscoreList();
  879.                     DrawSplashScreen();
  880.                     BlitWorkMapToScreen();
  881.                     break;
  882.                 case 5:    //seperator
  883.            
  884.                     break;
  885.                 case 6://about
  886.                                 DoAbout();
  887.                     break;
  888.                             
  889.                             //Controls
  890.                 case 7:
  891.                                 DoControls();
  892.                     break;
  893.                                 
  894.                             //Credits
  895.                 case 8:
  896.                                 DoCredits();
  897.                     break;
  898.                     
  899.                         //Disclaimer
  900.                case 9:
  901.                                DoDisclaimer();
  902.                     break;
  903.                case 10:
  904.                     break;
  905.                             //quit
  906.                case 11:
  907.                                gDone = true;
  908.                     break;
  909.             }
  910.             break;
  911.                 
  912.         //Edit Menu
  913.         case 1002:
  914.           
  915.             break;
  916.         //Options Menu
  917.         case 1003:
  918.                     switch(menuItem)
  919.                     {
  920.                         //sound effects
  921.                         case 1:
  922.                             prefs.sound = !prefs.sound;
  923.                             break;
  924.                         //music
  925.                         case 2:
  926.                             prefs.music = !prefs.music;
  927.                             break;
  928.                         //seperaotr
  929.                         case 3:
  930.                             break;
  931.                         
  932.                         case 4://fullscreen
  933.                             if (IsMenuBarVisible())
  934.                             {
  935.                                 HideMenuBar();
  936.                                 if (gWhere == kSplashScreen)
  937.                                 {
  938.                                     DrawSplashScreen();
  939.                                 }
  940.                             }
  941.                             else
  942.                             {
  943.                                 ShowMenuBar();
  944.                                 /*if (gWhere == kSplashScreen)
  945.                                 {
  946.                                     DrawSplashScreen();
  947.                                 }*/
  948.                             }
  949.                             break;
  950.                         
  951.                         case 5://change res
  952.                             if (gWhere != kGamePaused)
  953.                             {
  954.                                 PauseGame();
  955.                             }
  956.                             else
  957.                             {
  958.                                 EndPause();
  959.                             }
  960.                             break;
  961.                       
  962.                     
  963.                     }
  964.             break;
  965.         case 1004:
  966.             switch(menuItem)
  967.             {
  968.                 case 1:
  969.                     //No Chainsaw Jamming
  970.                     prefs.noChainsawJamming = !prefs.noChainsawJamming;
  971.                     if (prefs.noChainsawJamming)
  972.                         DoAlert("¥pNotification!", "¥pDisabling Chainsaw Jamming prevents entrance to the High Score Chart.");
  973.                     break;
  974.                 //Seperator
  975.                 case 2:
  976.                     break;
  977.                 //Fixed Framerate
  978.                 case 3:
  979.                     prefs.fixedFrameRate = !prefs.fixedFrameRate;
  980.                     if (!prefs.fixedFrameRate)
  981.                         DoAlert("¥pWarning", "¥pTurning off Fixed Frame Rate may result in the game being unplayable if you have a decently fast system.");
  982.                     break;
  983.                 //framerate 15
  984.                 case 4:
  985.                     prefs.drawFPS = !prefs.drawFPS;
  986.                     break;
  987.                 //seperator
  988.                 case 5:
  989.   
  990.                     break;
  991.                  //Max FPS report
  992.                 case 6:
  993.                     break;
  994.                
  995.             }
  996.             break;     
  997.     }
  998.     
  999.     
  1000.     DrawMenuBar();    
  1001.  
  1002. }
  1003.  
  1004.  
  1005. //////////////////////////////////////////////////////
  1006. ////Handle general mouse activity
  1007. //////////////////////////////////////////////////////
  1008.  
  1009. void HandleMouse (EventRecord *myEvent)
  1010. {
  1011.     long            menuChoice;
  1012.     short           windowPart;
  1013.     WindowPtr       hitWindow;
  1014.     
  1015.     //if we're in MacOS X, it doesnォt register the DrawSprockets screen as a window
  1016.     //hence, we just handle the click in global coordinates and we know it was in 
  1017.     //content since it's not possible to press anything else
  1018.     if (gOS == kMacOSX)
  1019.     {
  1020.         HandleClick(myEvent->where);
  1021.         return;
  1022.     }
  1023.     
  1024.     //get window in which it occurred
  1025.     windowPart = FindWindow(myEvent->where, &hitWindow);
  1026.  
  1027.     switch (windowPart)
  1028.     {
  1029.         //menu
  1030.         case inMenuBar:
  1031.             menuChoice = MenuSelect(myEvent->where);
  1032.             if (menuChoice)
  1033.             {
  1034.                 HandleMenus(menuChoice);
  1035.             }
  1036.             HiliteMenu(0);
  1037.             break;
  1038.         
  1039.         //within window    
  1040.         case inContent:
  1041.             GlobalToLocal(&myEvent->where);
  1042.             HandleClick(myEvent->where);
  1043.               break;
  1044.  
  1045.         //There is no close box
  1046.         //close box pressed
  1047.         /*case inGoAway:
  1048.             QuitApp();
  1049.             break;*/
  1050.      }
  1051. }
  1052.  
  1053. //////////////////////////////////////////////////////
  1054. ////Respond to click in content screen
  1055. //////////////////////////////////////////////////////
  1056. void HandleClick (Point where)
  1057. {
  1058.     short     i;
  1059.     
  1060.     switch(gWhere)
  1061.     {
  1062.     
  1063.         case kSplashScreen:
  1064.             for (i = 0; i < 6; i++)
  1065.             {
  1066.                 if (PtInRect(where, &splashButtonRects[i]))
  1067.                 {
  1068.                     ShadeRect(&splashButtonRects[i]);
  1069.                     while (Button())
  1070.                     {
  1071.                   
  1072.                     }
  1073.                     
  1074.                     switch(i)
  1075.                     {
  1076.                         case 0://new game
  1077.                             NewGame();
  1078.                             break;
  1079.                         case 1://configure
  1080.                             DoControls();
  1081.                             break;
  1082.                         case 2://about
  1083.                               DoAbout();
  1084.                             break;
  1085.                         case 3://credits
  1086.                             DoCredits();
  1087.                             break;
  1088.                         case 4://disclaimer
  1089.                             DoDisclaimer();
  1090.                             break;
  1091.                         case 5://quit
  1092.                             QuitApp();
  1093.                             break;
  1094.                     }
  1095.                         
  1096.                 }
  1097.             }
  1098.             if (PtInRect(where, &billHeadRect))
  1099.             {
  1100.                 if (prefs.sound)
  1101.                 {
  1102.                     SilenceChannel(otherSndChannel);
  1103.                     SndPlay(otherSndChannel, (SndListHandle)billScreamSnd, true);
  1104.                 }
  1105.             }
  1106.             if (PtInRect(where, &nedHeadRect))
  1107.             {
  1108.                 if (prefs.sound)
  1109.                 {
  1110.                     SilenceChannel(otherSndChannel);
  1111.                     SndPlay(otherSndChannel, (SndListHandle)yeahSnd, true);
  1112.                 }
  1113.             }
  1114.             if (PtInRect(where, &chainsawRect))
  1115.             {
  1116.                 if (prefs.sound)
  1117.                 {
  1118.                     SilenceChannel(otherSndChannel);
  1119.                     SndPlay(otherSndChannel, (SndListHandle)chainsawSnd, true);
  1120.                 }
  1121.             }
  1122.             
  1123.             break;
  1124.             
  1125.             
  1126.         case kAbout:
  1127.             DoMoreAbout();
  1128.             break;
  1129.         case kMoreAbout:
  1130.             DoSplashScreen();
  1131.             break;
  1132.         case kDisclaimer:
  1133.             DoSplashScreen();
  1134.             break;
  1135.         case kCredits:
  1136.             DoSplashScreen();
  1137.             break;
  1138.         case kControls:
  1139.             DoSplashScreen();
  1140.             break;
  1141.         case kGamePaused:
  1142.             //if the pause cooldown period has completed, we return to game
  1143.             i = TickCount();
  1144.             if (i - pauseTime > kPauseCooldown)
  1145.             {
  1146.                 EndPause();
  1147.             }
  1148.             break;
  1149.         case kHighScore:
  1150.             if (PtInRect(where, &textFieldRect))
  1151.             {
  1152.                 TEClick(where, false, playerNameTextField);
  1153.             }
  1154.             break;
  1155.         case kGameWon:
  1156.             //OK, the player has won the game. He clicked.
  1157.             //Now, let's check if he made it to the highscore
  1158.             if (!Button())
  1159.                 return;
  1160.             player.place = CheckPlaceInHighscoreList();
  1161.  
  1162.                //player made it on high score list
  1163.                if (player.place < 16)
  1164.                {
  1165.                    if (prefs.sound)
  1166.                    {
  1167.                        SndPlay(otherSndChannel, (SndListHandle)yeahSnd, true);
  1168.                    }
  1169.                    DoGetPlayerName();
  1170.                }
  1171.                else
  1172.                {
  1173.                    EndGame();
  1174.                }
  1175.             break;
  1176.         case kPerformance:
  1177.             DoSplashScreen();
  1178.             break;
  1179.     }
  1180.  
  1181. }
  1182.  
  1183. //////////////////////////////////////////////////////
  1184. ////Update screen contents by drawing current workmap
  1185. //////////////////////////////////////////////////////
  1186.  
  1187. void HandleUpdate (void)
  1188. {
  1189.     CGrafPtr    frontBuffer, backBuffer;
  1190.     
  1191.     DSpContext_GetFrontBuffer(gDisplayContext, &frontBuffer);
  1192.     DSpContext_GetBackBuffer(gDisplayContext, kDSpBufferKind_Normal, &backBuffer);
  1193.     
  1194.     //BeginUpdate((WindowRef) theWindow);
  1195.     SetPort(frontBuffer);
  1196.                 
  1197.     CopyBits(GetPortBitMapForCopyBits(backBuffer), GetPortBitMapForCopyBits(frontBuffer), &screenSize, &screenSize, srcCopy, nil);
  1198.  
  1199.     //EndUpdate((WindowRef) theWindow);
  1200.     
  1201.     if (gWhere == kHighScore)
  1202.             TEUpdate  (&textFieldRect, playerNameTextField);
  1203. }
  1204.  
  1205.  
  1206.  
  1207.  
  1208. #pragma mark -
  1209. //////////////////////////////////////////////////////
  1210. ////Go to all the different game screens
  1211. //////////////////////////////////////////////////////
  1212.  
  1213.  
  1214. void DoAbout (void)
  1215. {
  1216.     DrawAboutScreen();
  1217.     
  1218.     gWhere = kAbout;
  1219.     
  1220.     //play zoom sound
  1221.     if (prefs.sound)
  1222.     {
  1223.         SilenceChannel(otherSndChannel);
  1224.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1225.     }
  1226.       
  1227.       ZoomBlitWorkMapToScreen();
  1228. }
  1229.  
  1230.  
  1231. void DoMoreAbout (void)
  1232. {
  1233.     DrawMoreAboutScreen();
  1234.  
  1235.     gWhere = kMoreAbout;
  1236.  
  1237.     //play zoom sound
  1238.     if (prefs.sound)
  1239.     {
  1240.         SilenceChannel(otherSndChannel);
  1241.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1242.     }
  1243.             
  1244.     ZoomBlitWorkMapToScreen();
  1245. }
  1246.  
  1247.  
  1248. void DoDisclaimer (void)
  1249. {
  1250.     DrawDisclaimerScreen();
  1251.     
  1252.     gWhere = kDisclaimer;
  1253.     
  1254.     //play zoom sound
  1255.     
  1256.     if (prefs.sound)
  1257.     {
  1258.         SilenceChannel(otherSndChannel);
  1259.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1260.     }
  1261.             
  1262.       ZoomBlitWorkMapToScreen();
  1263. }
  1264.  
  1265. void DoCredits (void)
  1266. {
  1267.     gWhere = kCredits;
  1268.     
  1269.     DrawCreditsScreen();
  1270.     
  1271.     //play zoom sound
  1272.     
  1273.     if (prefs.sound)
  1274.     {
  1275.         SilenceChannel(otherSndChannel);
  1276.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1277.     }
  1278.             
  1279.     ZoomBlitWorkMapToScreen();
  1280. }
  1281.  
  1282. void DoControls (void)
  1283. {
  1284.     DrawControlsScreen();
  1285.     
  1286.     gWhere = kControls;
  1287.     
  1288.     //play zoom sound
  1289.     if (prefs.sound)
  1290.     {
  1291.         SilenceChannel(otherSndChannel);
  1292.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1293.     }
  1294.             
  1295.     ZoomBlitWorkMapToScreen();
  1296.  
  1297. }
  1298.  
  1299.  
  1300. void DoSplashScreen (void)
  1301. {
  1302.     DrawSplashScreen();
  1303.     
  1304.     gWhere = kSplashScreen;
  1305.     
  1306.     if (prefs.sound)
  1307.     {
  1308.         SilenceChannel(otherSndChannel);
  1309.         SndPlay(otherSndChannel, (SndListHandle)zoomSnd, true);
  1310.     }
  1311.     ZoomBlitWorkMapToScreen();
  1312.     
  1313.     DrawMenuBar();
  1314.  
  1315. }
  1316.  
  1317. #pragma mark -
  1318.  
  1319. //////////////////////////////////////////////////////
  1320. ////Reset the highscore settings to default
  1321. //////////////////////////////////////////////////////
  1322. void ClearHighscoreList (void)
  1323. {
  1324.     short i;
  1325.  
  1326.     for (i = 0; i < 16; i++)
  1327.     {
  1328.         pStrcpy(prefs.highscores.name[i], kDefaultName);
  1329.         prefs.highscores.score[i] = 160-(i*10);
  1330.     }
  1331.     
  1332.     prefs.lastHighScore = kNoHighScoreSet;
  1333. }
  1334.  
  1335.  
  1336.  
  1337.  
  1338. #pragma mark -
  1339. //APPLE EVENT STUFF
  1340.  
  1341.  
  1342. //////////////////////////////////////////////////////
  1343. ////Handle an Apple Event Quit.  We ignore the rest
  1344. //////////////////////////////////////////////////////
  1345. OSErr HandleAEQuitApp(const AppleEvent *theAppleEvent, AppleEvent *reply, long refCon)
  1346. {
  1347.     QuitApp();
  1348.     return MyGotRequiredParams(theAppleEvent);    
  1349. }
  1350.  
  1351. void AppleEventInit(void)
  1352. {
  1353.         AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)HandleAEQuitApp), 0L, false);
  1354. }
  1355.  
  1356. OSErr MyGotRequiredParams(const AppleEvent *theAppleEvent)
  1357. {
  1358.     DescType returnedType;
  1359.     Size actualSize;
  1360.  
  1361.     if ( AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, &returnedType, nil, 0, &actualSize) == errAEDescNotFound )
  1362.     {
  1363.         return noErr;
  1364.     }
  1365.     else
  1366.     {
  1367.         return errAEParamMissed;
  1368.     } 
  1369. }
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.